package com.rw.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component()
@Aspect
public class MyAdvice {

    @Before("com.rw.test.RoundInterfaceImpl.printInfo()")
    public void testBefore(){
        System.out.println("前置通知的方法");
    }


    @After("com.rw.test.RoundInterfaceImpl.printInfo()")
    public void testAfter(){
        System.out.println("后置通知的方法");
    }


    @Around(value = "com.rw.test.RoundInterfaceImpl.printInfo()")
    public void testRound(ProceedingJoinPoint point) throws Throwable {
        System.out.println("环绕通知的前置方法");
        point.proceed();

        System.out.println("环绕通知的后置方法");
    }

    @AfterThrowing(value = "com.rw.test.RoundInterfaceImpl.printInfo()",throwing="ex")
    public void testThrow(Exception ex){
        System.out.println("异常通知的方法"+ex.getMessage());
    }
}
